﻿using System;
using System.Collections.Generic;

namespace DoNet.SFExpress.Framework.SCS_PUSH
{
    /// <summary>
    /// 冷运API
    /// </summary>
    public class ScsPushApi
    {
        #region 冷运运输类

        /// <summary>
        /// 冷运推送运单费用明细
        /// 顺丰主动将订单费用明细推送客户，包含“运费、增值服务费用”；
        /// </summary>
        /// <param name="body">顺丰推送过来的数据</param>
        /// <param name="reqData">顺丰推送过来的数据转换后的实体</param>
        /// <returns></returns>
        public static MsgDataResponseTransportFeeDetails TransportFeeDetails(string body, out MsgDataRequestTransportFeeDetails reqData)
        {
            /*
            1.功能描述：
            ​ 顺丰主动将订单费用明细推送客户，包含“运费、增值服务费用”；

            2.接口定义
            名称	值
            接口服务代码	SCS_PUSH_TRANSPORT_FEE_DETAILS
            批量交易	不支持
            接口类型	推送（SF->客户）
            报文类型	JSON

            3.报文(JSON)示例
            请求示例

            {
              "totalAmount": 7748,
              "feeDetails": [
                {
                  "amount": 5,
                  "feeName": "保费",
                  "confirmTime": "2021-05-14 14:44:18",
                  "serviceCode": "VA0021"
                },
                {
                  "amount": 20,
                  "feeName": "动检证",
                  "confirmTime": "2021-05-14 14:44:18",
                  "serviceCode": "VA0035"
                },
                {
                  "amount": 100,
                  "feeName": "提货服务",
                  "confirmTime": "2021-05-14 14:44:18",
                  "serviceCode": "VA0058"
                },
                {
                  "amount": 1984,
                  "feeName": "配送服务",
                  "confirmTime": "2021-05-14 14:44:18",
                  "serviceCode": "VA0059"
                }
              ],
              "versionTime": "2021-05-14 14:44:18",
              "waybillNo": "SF700201271693151"
            }

            2.2返回参数
            参数名	类型	说明	是否必传
            success	Boolean	结果 true成功，false异常 为空都会重推送	N
            msg	String	错误原因	N

            成功示例

            {
              "msg": "接收成功",
              "success": false
            }
            失败示例（系统会重推）

            {
              "msg": "失败",
              "success": true
            } 
            */
            MsgDataResponseTransportFeeDetails result = new MsgDataResponseTransportFeeDetails()
            {
                success = false,
                msg = "失败"
            };

            if (!string.IsNullOrEmpty(body))
            {
                reqData = JsonHelper.DeserializeObject<MsgDataRequestTransportFeeDetails>(body);
                if (reqData != null)
                {
                    result = new MsgDataResponseTransportFeeDetails()
                    {
                        success = true,
                        msg = "接收成功"
                    };
                }
            }
            else
            {
                reqData = null;
            }
            return result;
        }

        /// <summary>
        /// 冷运推送订单信息接口 SCS_PUSH_ORDER_INFO
        /// 通过此接口顺丰主动将订单更新的详细信息推送给客户（包括：更新的收寄件人、重量、商品信息、签回单）
        /// </summary>
        /// <param name="body">顺丰推送过来的数据</param>
        /// <param name="reqData">顺丰推送过来的数据转换后的实体</param>
        /// <returns></returns>
        public static SFResponseApiResultData OrderInfo(string body, out MsgDataRequestOrderInfo reqData)
        {
            /*
            2.接口定义
            名称	值
            接口服务代码	SCS_PUSH_ORDER_INFO
            批量交易	不支持
            接口类型	推送（SF->客户）
            报文类型	JSON
            2.1请求参数
            字段名	是否必填	类型	字段描述
            order	Object		
            sourceCode	N	字符(64)	订单来源
            orderNo	N	字符(64)	订单编号
            erpNo	N	字符(64)	ERP单号（客户系统订单号）
            monthlyAccount	N	字符(64)	月结卡号
            orderStatus	N	字符(64)	订单状态
            productCode	N	字符(64)	产品类型代码
            paymentTypeCode	N	字符(64)	付款方式代码
            createTime	N	字符(64)	下单时间
            confirmTime	N	字符(64)	收货确认时间
            signTime	N	字符(64)	签收时间
            temperatureLevelName	N	字符(64)	温层名称
            temperatureLevelCode	N	字符(64)	温层代码
            grossWeight	N	number	实际总重量
            meterageWeight	N	number	计费总重量
            waybillNo	N	字符(64)	主运单号
            waybillCount	N	integer	运单数量（子母件数量）
            returnWaybillNo	N	字符(64)	签回单号
            pickupType	N	字符(64)	提货方式
            distributionType	N	字符(64)	配送方式
            senderCompany	N	字符(64)	发货公司
            senderName	N	字符(64)	发货人姓名
            senderMobile	N	字符(64)	发货人手机号
            senderPhone	N	字符(64)	发货人座机号
            senderCountryName	N	字符(64)	发货国家名称
            senderProvinceName	N	字符(64)	客户发货地址（小哥收件地址）-省名称
            senderCityName	N	字符(64)	客户发货地址（小哥收件地址）-市名称
            senderAreaName	N	字符(64)	客户发货地址（小哥收件地址）-区名称
            senderDetailAddress	N	字符(64)	客户发货地址（小哥派件地址）-详细地址
            senderWebsiteName	N	字符(64)	客户发货地址（小哥收件地址）-网点名称
            receiverCompany	N	字符(64)	收货公司
            receiverName	N	字符(64)	收货人姓名
            receiverMobile	N	字符(64)	收货人手机号
            receiverCountryName	N	字符(64)	收货国家名称
            receiverProvinceName	N	字符(64)	客户收货地址（小哥派件地址）-省份名称
            receiverCityName	N	字符(64)	客户收货地址（小哥派件地址）-城市名称
            receiverDetailAddress	N	字符(64)	客户收货地址（小哥派件地址）-详细地址
            receiverAreaName	N	字符(64)	客户收货地址（小哥派件地址）-区名称
            receiverWebsiteName	N	字符(64)	收货网点名称
            delivererName	N	字符(64)	派件员姓名
            delivererMobile	N	字符(64)	派件员手机号
            driverName	N	字符(64)	司机姓名
            driverMobile	N	字符(64)	司机手机
            carNo	N	字符(64)	车牌号
            carType	N	字符(64)	车型

            childWaybillList	Array		子单列表信息
            childWaybillNo	N	字符(64)	子单号

            orderGoodsList	Array	新的	
            skuCode	Y	字符(64)	商品类别
            skuName	Y	字符(128)	商品名称
            quantity	integer	否	箱数,件
            grossWeight	Y	数字(18,3)	实重(kg)
            volume	Y	数字(18,6)	体积(m3)
            sku	N	字符(64)	商品编码SKU
            skuNumber	N	数字(11)	商品数量
            skuUnit	N	字符(32)	计量单位，类似个、只
            remark	N	字符(200)	备注

            orderServiceList	Array		
            monthlyAccount	N	字符(64)	月结卡号
            paymentTypeCode	N	字符(64)	付款方式编码
            serviceCode	N	字符(64)	增值服务编码
            feeAmount	N	number	费用金额
            extensionInfo	N	字符(64)	扩展信息

            orderReturn	Object		
            returnWaybillNo	N	字符(64)	签回单号
            senderCompany	N	字符(64)	发货公司
            senderName	N	字符(64)	发货人
            senderMobile	N	字符(64)	发货人手机号
            senderPhone	N	字符(64)	发货人座机号码
            senderCountryName	N	字符(64)	客户发货地址（小哥收件地址）-国家名称
            senderProvinceName	N	字符(64)	客户发货地址（小哥收件地址）-省名称
            senderCityName	N	字符(64)	客户发货地址（小哥收件地址）-市名称
            senderAreaName	N	字符(64)	客户发货地址（小哥收件地址）-区名称
            senderDetailAddress	N	字符(64)	客户发货地址（小哥收件地址）-详细地址
            receiverCompany	N	字符(64)	收货公司
            receiverName	N	字符(64)	收货人姓名
            receiverMobile	N	字符(64)	收货人手机号
            receiverPhone	N	字符(64)	收货人座机号码
            receiverCountryName	N	字符(64)	客户收货地址（小哥派件地址）-国家名称
            receiverProvinceName	N	字符(64)	客户收货地址（小哥派件地址）-省名称
            receiverCityName	N	字符(64)	客户收货地址（小哥派件地址）-市名称
            receiverAreaName	N	字符(64)	客户收货地址（小哥派件地址）-区名称
            receiverDetailAddress	N	字符(64)	客户收货地址（小哥派件地址）-详细地址

            2.2返回参数
            参数名	类型	说明	是否必传
            success	Boolean	结果 true成功，false异常 为空都会重推送	N
            msg	String	错误原因	N
            3.报文(JSON)示例
            请求示例

            {
                "partnerID": "", 
                "requestID": "", 
                "serviceCode": "", 
                "timestamp": 1254852, 
                "ak": "", 
                "nonce": 12, 
                "fromCode": "", 
                "msgData": {
                    "order": {
                        "orderNo": "TP590256644432453632", 
                        "waybillNo": "SF7001013145610", 
                        "erpNo": "A01000009", 
                        "productCode": "SE003001", 
                        "productName": "冷运小票零担", 
                        "senderCountryName": "中国", 
                        "senderProvinceName": "广东省", 
                        "senderCityName": "深圳市", 
                        "senderAreaName": "福田区", 
                        "senderDetailAddress": "万基商务大厦", 
                        "senderWebsiteName": "深圳清湖食品中转场", 
                        "senderName": "张三", 
                        "senderMobile": "13125478964", 
                        "paymentTypeCode": "PR_CASH", 
                        "paymentType": "寄付现结", 
                        "receiverCountryName": "中国", 
                        "receiverProvinceName": "广东省", 
                        "receiverCityName": "深圳市", 
                        "receiverAreaName": "南山区", 
                        "receiverDetailAddress": "彩讯科创中心", 
                        "receiverWebsiteName": "深圳清湖食品配送部", 
                        "receiverName": "李四", 
                        "receiverMobile": "13587456987", 
                        "pickupType": "上门提货", 
                        "distributionType": "送货上门", 
                        "isSpecialWarehousing": "N", 
                        "sourceCode": "E-POST", 
                        "orderStatus": "已审核", 
                        "meterageWeight": 5000, 
                        "orderRemark": "测的玩", 
                        "createTime": "2021-05-13 16:30:17", 
                        "temperatureLevelCode": "2", 
                        "temperatureLevelName": "0至10", 
                        "returnWaybillNo": "SF7001111675329", 
                        "carType": "4.2米-食品-冷运-冷藏", 
                        "importedFlag": 1
                    }, 
                    "orderServiceList": [
                        {
                            "serviceCode": "VA0021", 
                            "serviceName": "保价", 
                            "paymentTypeCode": "PR_CASH", 
                            "paymentType": "寄付现结", 
                            "extensionInfo": "{\"declareValue\":\"50000\"}"
                        }, 
                        {
                            "serviceCode": "VA0003", 
                            "serviceName": "签单返还", 
                            "paymentTypeCode": "PR_CASH", 
                            "paymentType": "寄付现结", 
                            "extensionInfo": "{\"retrunOrderRemark\":\"null\",\"returnOrderType\":\"签名\"}"
                        }
                    ], 
                    "orderGoodsList": [
                        {
                            "skuCode": "牛肉", 
                            "skuName": "牛肉", 
                            "quantity": 10, 
                            "grossWeight": 50, 
                            "volume": 15
                        }
                    ], 
                    "orderReturn": {
                        "returnWaybillNo": "SF7001111675329", 
                        "receiverName": "张三", 
                        "receiverMobile": "13125478964", 
                        "receiverCountryName": "中国", 
                        "receiverProvinceName": "广东省", 
                        "receiverCityName": "深圳市", 
                        "receiverAreaName": "福田区", 
                        "receiverDetailAddress": "万基商务大厦"
                    }
                }
            }
            成功示例（apiResultData）

            {
	            "apiErrorMsg": "",
	            "apiResponseID": "12345678",
	            "apiResultCode": "A1000",
	            "apiResultData": "{\"msg\":\"接收成功\",\"success\":true}"
            }
            失败示例（系统会重推）

            {
              "apiResultCode": "A1099",
               "apiErrorMsg": "系统异常",
               "apiResponseID": "161553468411dd",
               "apiResultData":""
            }
            */
            string apiResultCode = "A1099";
            string apiErrorMsg = "系统异常";
            string apiResponseID = Guid.NewGuid().ToString();
            string apiResultData = "";

            if (!string.IsNullOrEmpty(body))
            {
                var request = JsonHelper.DeserializeObject<OrderInfoRequest>(body);
                if (request != null)
                {
                    reqData = request.msgData;
                    MsgDataResponseOrderInfo result = new MsgDataResponseOrderInfo()
                    {
                        success = true,
                        msg = "接收成功"
                    };
                    apiResultCode = "A1000";
                    apiErrorMsg = "";
                    apiResultData = JsonHelper.SerializeObject(result);
                }
                else
                {
                    reqData = null;
                }
            }
            else
            {
                reqData = null;
            }
            return new SFResponseApiResultData()
            {
                apiResultCode = apiResultCode,
                apiErrorMsg = apiErrorMsg,
                apiResponseID = apiResponseID,
                apiResultData = apiResultData
            };
        }

        /// <summary>
        /// 冷运推送订单状态接口 SCS_PUSH_ORDER_STATE
        /// 通过此接口顺丰主动将订单更新的详细信息推送给客户（包括：更新的收寄件人、重量、商品信息、签回单）
        /// </summary>
        /// <param name="body">顺丰推送过来的数据</param>
        /// <param name="reqData">顺丰推送过来的数据转换后的实体</param>
        /// <returns></returns>
        public static SFResponseApiResultData OrderState(string body, out MsgDataRequestOrderState reqData)
        {
            /*
            2.1请求参数
            字段名	是否必选项	类型	字段描述
            erpOrder	Y	字符(32)	ERP单号
            waybillNo	Y	字符(64)	SF生成运单号
            returnWaybillNo	N	字符(64)	SF生成签运单号
            orderStatus	Y	字符(32)	订单状态(已审核/已收件/已签收)
            time	Y	字符(64)	审核时间/收件时间/签收时间
            2.2返回参数
            参数名	类型	说明	是否必传
            success	Boolean	结果 true成功，false异常 为空都会重推送	N
            msg	String	错误原因	N
            3.报文(JSON)示例
            请求示例

            {
	            "erpOrder":"test123456"
	            "waybillNo":"SF7001234567890"
	            "returnWaybillNo":"SF2001234567890"
	            "orderStatus":"已收件"
	            "time":"2021-05-13 16:30:17"
            }
            返回示例

            成功示例

            {
	            "apiErrorMsg": "",
	            "apiResponseID": "12345678",
	            "apiResultCode": "A1000",
	            "apiResultData": "{\"msg\":\"接收成功\",\"success\":true}"
            }
            失败示例（系统会重推）

            {
              "apiResultCode": "A1099",
               "apiErrorMsg": "系统异常",
               "apiResponseID": "161553468411dd",
               "apiResultData":""
            }
            */
            string apiResultCode = "A1099";
            string apiErrorMsg = "系统异常";
            string apiResponseID = Guid.NewGuid().ToString();
            string apiResultData = "";

            if (!string.IsNullOrEmpty(body))
            {
                reqData = JsonHelper.DeserializeObject<MsgDataRequestOrderState>(body);
                if (reqData != null)
                {
                    MsgDataResponseOrderInfo result = new MsgDataResponseOrderInfo()
                    {
                        success = true,
                        msg = "接收成功"
                    };
                    apiResultCode = "A1000";
                    apiErrorMsg = "";
                    apiResultData = JsonHelper.SerializeObject(result);
                }
            }
            else
            {
                reqData = null;
            }
            return new SFResponseApiResultData()
            {
                apiResultCode = apiResultCode,
                apiErrorMsg = apiErrorMsg,
                apiResponseID = apiResponseID,
                apiResultData = apiResultData
            };
        }

        /// <summary>
        /// 冷运运输流向校验接口
        /// 客户按指定“流向+产品”，查询顺丰冷运可收派温层、网点营业时间；
        /// </summary>
        /// <param name="partnerID"></param>
        /// <param name="checkword"></param>
        /// <param name="data">业务数据报文 json字符串</param>
        /// <param name="environment">调用环境，bspgw：生产环境；sfapi-hk：香港生产环境；sfapi-sbox：沙箱环境</param>
        /// <returns></returns>
        public static JsonResult CheckTransportFlow(string partnerID, string checkword, MsgDataRequestCheckTransportFlow data, string accessToken = "", string environment = "bspgw")
        {
            /*
            2.1公共请求参数
            序号	参数列表	类型	是否必传	含义
            1	partnerID	String(64)	是	合作伙伴编码（即顾客编码）
            2	requestID	String(40)	是	请求唯一号UUID
            3	serviceCode	String(50)	是	接口服务代码（SCS_RECE_CHECK_TRANSPORT_FLOW）
            4	timestamp	long	是	调用接口时间戳
            5	msgDigest	String(128)	条件	数字签名,使用数字签名方式认证时必填 签名方法参考：数字签名认证说明
            6	accessToken	String(100)	条件	accessToken,使用OAuth2方式认证时必填 获取方法参考：OAuth2认证说明
            7	msgData	String	是	业务数据报文
            3.报文(JSON)示例
            请求示例<msgData>

            {
                  "productCode": "SE0030",
                  "receiverAddress": "北京大兴食品中",
                  "receiverCityAreaNumber": "010",
                  "receiverCityName": "北京市",
                  "receiverCountyName": "顺义区",
                  "receiverProvinceName": "北京",
                  "senderAddress": "深圳清湖食品配送部",
                  "senderCityAreaNumber": "755",
                  "senderCityName": "深圳市",
                  "senderCountyName": "南山区",
                  "senderProvinceName": "广东省"
            }
            
            2.3公共返回参数
            参数名	类型	说明	是否必传
            apiResultCode	String(10)	API平台结果代码，详见附录8	Y
            apiErrorMsg	String(200)	API平台异常信息	N
            apiResponseID	String(40)	API响应唯一号UUID	Y
            apiResultData	String	业务处理详细结果（JSON对象字符串格式：JSON.toJSONString(ResponseModel)	N
            2.4业务返回参数<apiResultData>
            参数名	类型	说明
            code	字符(32)	接口状态 0 成功 其它异常
            message	字符(500)	返回信息展示
            data	对象	model
            success	boolean	true 成功 false 异常
            model对象

            参数名	类型	说明
            senderInfo	DTO	寄件服务网点信息
            serviceType	字符	服务类型
            netpoint	DTO	网点信息
            mdneUnitName	字符	网点名称
            mdneDetailedAddress	字符	网点地址
            mdneContactPhone	字符	联系电话
            mdneOuterBusinessStarttime	字符	对外营业时间开始
            mdneOuterBusinessEndtime	字符	对外营业时间结束
            receiverInfo	DTO	与senderInfo字段属性一致
            temperatureLevel	DTO	可选的温层信息
            ebcdCode	字符	温控代码
            ebcdNameCn	字符	温控名称
            ebcdSquenceNo	字符	序号
            ebcdTemperatureType	字符	温控类型
            ebcdProductCode	字符	产品代码
            返回示例

            成功示例

            {
              "code": "0",
              "data": {
                "senderInfo": {
                  "serviceType": "DISPATCH",
                  "netpoint": {
                    "mdneUnitName": "深圳清湖食品配送部",
                    "mdneDetailedAddress": "广东省深圳市龙华新区深圳市宝安区龙华新区清湖社区清祥路23号清湖冷链物流园561",
                    "mdneContactPhone": "123456435",
                    "mdneOuterBusinessStarttime": "09:00",
                    "mdneOuterBusinessEndtime": "21:50"
                  }
                },
                "receiverInfo": {
                  "serviceType": "ONLY_PICK_UP",
                  "netpoint": {
                    "mdneUnitName": "北京大兴食品中转场",
                    "mdneDetailedAddress": "北京市大兴区长子营开发区企融路1号",
                    "mdneContactPhone": "01025708989",
                    "mdneOuterBusinessStarttime": "00:00",
                    "mdneOuterBusinessEndtime": "23:30"
                  }
                },
                "temperatureLevel": [
                  {
                    "ebcdCode": "2",
                    "ebcdNameCn": "0至10",
                    "ebcdTemperatureType": "冷藏",
                    "ebcdSquenceNo": 1,
                    "ebcdProductCode": "SE0030"
                  },
                  {
                    "ebcdCode": "30",
                    "ebcdNameCn": "冷冻",
                    "ebcdTemperatureType": "冷冻",
                    "ebcdSquenceNo": 4,
                    "ebcdProductCode": "SE0030"
                  },
                  {
                    "ebcdCode": "31",
                    "ebcdNameCn": "常温（环境温度）",
                    "ebcdTemperatureType": "常温",
                    "ebcdSquenceNo": 3,
                    "ebcdProductCode": "SE0030"
                  }
                ]
              },
              "success": true,
              "message": "success"
            }
            错误示例

            {
              "code": "133",
              "data": "",
              "message": "该流向不存在",
              "success": false
            } 
            */
            string errcode = "";
            string errmsg = "";
            string resultdata = "";

            string serviceCode = "SCS_RECE_CHECK_TRANSPORT_FLOW";
            string msgData = SFCommon.JsonCompress(JsonHelper.SerializeObject(data));
            string timestamp = SFCommon.GetTimeStamp(); //获取时间戳
            string requestID = Guid.NewGuid().ToString(); //获取uuid

            Dictionary<string, string> content = new Dictionary<string, string>();
            content["partnerID"] = partnerID;
            content["requestID"] = requestID;
            content["serviceCode"] = serviceCode;
            content["timestamp"] = timestamp;
            if (!string.IsNullOrWhiteSpace(accessToken))
            {
                content["accessToken"] = accessToken;
            }
            else
            {
                string msgDigest = SFCommon.MD5ToBase64String(SFCommon.UrlEncode(msgData + timestamp + checkword));
                content["msgDigest"] = msgDigest;
            }
            content["msgData"] = msgData;

            var result = HttpHelper.GetResponseApiResultData(content, null, environment);
            if (result != null)
            {
                if (result.apiResultCode == "A1000")
                {
                    var msgDataResponse = JsonHelper.DeserializeObject<ApiResultDataResponseCheckTransportFlow>(result.apiResultData);
                    if (msgDataResponse != null)
                    {
                        errmsg = msgDataResponse.message;
                        resultdata = JsonHelper.SerializeObject(msgDataResponse.data);
                        if (msgDataResponse.success)
                        {
                            errcode = "0";
                        }
                        else
                        {
                            errcode = msgDataResponse.code;
                        }
                    }
                    else
                    {
                        errcode = "-2";
                        errmsg = "未返回业务数据";
                        resultdata = "";
                    }
                }
                else
                {
                    errcode = result.apiResultCode;
                    errmsg = result.apiErrorMsg;
                    resultdata = result.apiResultData;
                }
            }
            else
            {
                errcode = "-1";
                errmsg = "接口未返回内容";
                resultdata = "";
            }

            return new JsonResult
            {
                errcode = errcode,
                errmsg = errmsg,
                data = resultdata
            };
        }

        /// <summary>
        /// 冷运运输预估费用接口
        /// 客户按指定“流向+产品(多)”，查询预估费用明细
        /// </summary>
        /// <param name="partnerID"></param>
        /// <param name="checkword"></param>
        /// <param name="data">业务数据报文 json字符串</param>
        /// <param name="environment">调用环境，bspgw：生产环境；sfapi-hk：香港生产环境；sfapi-sbox：沙箱环境</param>
        /// <returns></returns>
        public static JsonResult CalcTransportFee(string partnerID, string checkword, MsgDataRequestCalcTransportFee data, string accessToken = "", string environment = "bspgw")
        {
            /*
            3.报文(JSON)示例
            请求示例<msgData>

            {
                    "erpOrder": "1233",
                    "productCode": "SE0030,SE003001",
                    "orderTime": "2021-05-01 12:12:12",
                    "shipperProvinceName": "上海",
                    "shipperCityName": "上海市",
                    "shipperDistrictName": "黄浦区",
                    "shipperLocationName": "萧山区党柯路96-1号",
                    "consigneeProvinceName": "广东省",
                    "consigneeCityName": "深圳市",
                    "consigneeDistrictName": "南山区",
                    "consigneeLocationName": "软件产业基地",
                    "orderItems": [{
                        "grossWeight": "12",
                        "volume": "12"
                    }],
                    "orderServices": [{
                            "serviceValue": "签单返还",
                            "serviceCode": "VA0003",
                            "userDef1": "signature,stamp,identityCard,idNo,other",
                            "userDef2": "测试"
                        },
                        {
                            "serviceValue": "3000",
                            "serviceCode": "VA0021"
                        },
                        {
                            "serviceCode": "VA0058",
                            "serviceName": "提货服务"
                        },
                        {
                            "serviceCode": "VA0059",
                            "serviceName": "配送服务"
                        }
                    ]

            }

            2.3公共返回参数
            参数名	类型	说明	是否必传
            apiResultCode	String(10)	API平台结果代码，详见附录8	Y
            apiErrorMsg	String(200)	API平台异常信息	N
            apiResponseID	String(40)	API响应唯一号UUID	Y
            apiResultData	String	业务处理详细结果（JSON对象字符串格式：JSON.toJSONString(ResponseModel)	N
            2.4业务返回参数<apiResultData>
            参数名	类型	说明
            code	字符(32)	接口状态 0 成功 其它异常
            message	字符(500)	返回信息展示
            data	Map<String,Model>	model
            success	boolean	true 成功 false 异常
            Map<String,Model>集合:

            参数名	类型	说明
            产品类型（SE0030或SE003001）	字符(32)	产品编码
            结果		
            参数名	类型	说明
            code	字符(32)	接口状态 200 成功 其它异常
            message	字符(500)	接口状态 200 成功 其它异常
            model	对象	详细请见model
            参数名	类型	说明
            feeName	字符(64)	费用名称
            serviceCode	字符(32)	增值服务代码
            totalAmount	数字	金额
            返回示例

            成功示例

            {
              "apiResultCode": "A1000",
              "apiErrorMsg": "",
              "apiResponseID": "161553468411dd",
              "apiResultData":{
                "code": "0",
                "data": {
                    "SE003001": {
                        "code": "200",
                        "message": "success",
                        "model": [{
                            "totalAmount": 5.00,
                            "feeName": "保费",
                            "serviceCode": "VA0021"
                        }, {
                            "totalAmount": 20.00,
                            "feeName": "动检证",
                            "serviceCode": "VA0035"
                        }, {
                            "totalAmount": 100.00,
                            "feeName": "提货服务",
                            "serviceCode": "VA0058"
                        }, {
                            "totalAmount": 1984.00,
                            "feeName": "配送服务",
                            "serviceCode": "VA0059"
                        }
                                 ]
                    },
                    "SE0030": {
                        "code": "200",
                        "message": "success",
                        "model": [{
                            "totalAmount": 5.00,
                            "feeName": "保费",
                            "serviceCode": "VA0021"
                        }, {
                            "totalAmount": 20.00,
                            "feeName": "动检证",
                            "serviceCode": "VA0035"
                        }, {
                            "totalAmount": 100.00,
                            "feeName": "提货服务",
                            "serviceCode": "VA0058"
                        }, {
                            "totalAmount": 1984.00,
                            "feeName": "配送服务",
                            "serviceCode": "VA0059"
                        }
                                 ]
                    }
                },
                "message": "success",
                "success": true
                } 

            }


            错误示例

            {
              "apiResultCode": "A1099",
              "apiErrorMsg": "系统异常",
              "apiResponseID": "161553468411dd",
              "apiResultData":""
            } 
            */
            string errcode = "";
            string errmsg = "";
            string resultdata = "";

            string serviceCode = "SCS_RECE_CALC_TRANSPORT_FEE";
            string msgData = SFCommon.JsonCompress(JsonHelper.SerializeObject(data));
            string timestamp = SFCommon.GetTimeStamp(); //获取时间戳
            string requestID = Guid.NewGuid().ToString(); //获取uuid

            Dictionary<string, string> content = new Dictionary<string, string>();
            content["partnerID"] = partnerID;
            content["requestID"] = requestID;
            content["serviceCode"] = serviceCode;
            content["timestamp"] = timestamp;
            if (!string.IsNullOrWhiteSpace(accessToken))
            {
                content["accessToken"] = accessToken;
            }
            else
            {
                string msgDigest = SFCommon.MD5ToBase64String(SFCommon.UrlEncode(msgData + timestamp + checkword));
                content["msgDigest"] = msgDigest;
            }
            content["msgData"] = msgData;

            var result = HttpHelper.GetResponseApiResultData(content, null, environment);
            if (result != null)
            {
                if (result.apiResultCode == "A1000")
                {
                    var msgDataResponse = JsonHelper.DeserializeObject<ApiResultDataResponseCalcTransportFee>(result.apiResultData);
                    if (msgDataResponse != null)
                    {
                        errmsg = msgDataResponse.message;
                        resultdata = JsonHelper.SerializeObject(msgDataResponse.data);
                        if (msgDataResponse.success)
                        {
                            errcode = "0";
                        }
                        else
                        {
                            errcode = msgDataResponse.code;
                        }
                    }
                    else
                    {
                        errcode = "-2";
                        errmsg = "未返回业务数据";
                        resultdata = "";
                    }
                }
                else
                {
                    errcode = result.apiResultCode;
                    errmsg = result.apiErrorMsg;
                    resultdata = result.apiResultData;
                }
            }
            else
            {
                errcode = "-1";
                errmsg = "接口未返回内容";
                resultdata = "";
            }

            return new JsonResult
            {
                errcode = errcode,
                errmsg = errmsg,
                data = resultdata
            };
        }

        /// <summary>
        /// 冷运运输预估时效接口
        /// 按指定“流向+产品(多)”，查询顺丰冷运预估时效及送达时间，含提货+派送时效
        /// </summary>
        /// <param name="partnerID"></param>
        /// <param name="checkword"></param>
        /// <param name="data">业务数据报文 json字符串</param>
        /// <param name="environment">调用环境，bspgw：生产环境；sfapi-hk：香港生产环境；sfapi-sbox：沙箱环境</param>
        /// <returns></returns>
        public static JsonResult EstimateDeliverTm(string partnerID, string checkword, MsgDataRequestEstimateDeliverTm data, string accessToken = "", string environment = "bspgw")
        {
            /*	
            3.报文(JSON)示例
            请求示例

            {
                  "consignTime": "2021-05-14 08:03:10",
                  "oneselfPickupFlg": 0,
                  "productCode": "SE0030,SE003001",
                  "receiverCityAreaNumber": "010",
                  "selfSendFlg": 0,
                  "senderCityAreaNumber": "755"
            }
            2.3公共返回参数
            参数名	类型	说明	是否必传
            apiResultCode	String(10)	API平台结果代码，详见附录8	Y
            apiErrorMsg	String(200)	API平台异常信息	N
            apiResponseID	String(40)	API响应唯一号UUID	Y
            apiResultData	String	业务处理详细结果（JSON对象字符串格式：JSON.toJSONString(ResponseModel)	N
            2.4业务返回参数<apiResultData>
            参数名	类型	说明
            code	字符(32)	接口状态 0 成功 其它异常
            message	字符(500)	返回信息展示
            data	List	model
            success	boolean	true 成功 false 异常
            model对象

            参数名	类型	说明
            productCode	字符	产品代码
            code	字符(32)	接口状态 200 成功 其它异常
            message	字符(500)	错误信息展示
            effectiveInfo.arriveTime	字符	预计到达时间
            effectiveInfo.delayRemark	字符	加时备注
            effectiveInfo.planDescription	字符	班次描述
            effectiveInfo.delayDay	字符	加时天数
            effectiveInfo.effectiveDay	字符	承诺天数
            返回示例

            成功示例

            {
               "apiResultCode": "A1000",
               "apiErrorMsg": "",
               "apiResponseID": "161553468411dd",
               "apiResultData": {
                    "code": "0",
                    "data": [
                        {
                          "productCode": "SE0030",
                           "code": "200",
                          "message": "success",
                          "effectiveInfo": {
                            "arriveTime": "2021-05-22 20:00:00",
                            "delayRemark": "sameCity111",
                            "planDescription": "每日发运",
                            "delayDay": "6",
                            "effectiveDay": "9"
                          }
                        },
                        {
                          "productCode": "SE003001",
                           "code": "200",
                          "message": "success",
                          "effectiveInfo": {
                            "arriveTime": "2021-05-23 18:00:00",
                            "delayRemark": "sameCity111",
                            "planDescription": "每日发运",
                            "delayDay": "7",
                            "effectiveDay": "10"
                          }
                        }
                      ],
                "message": "success",
                "success": true
                } 
            }
            错误示例

            {
              "apiResultCode": "A1000",,
              "apiErrorMsg": "",
              "apiResponseID": "161553468411dd",
              "apiResultData": {
                "code": "0",
                "data": [
                {
                  "productCode": "SE0030",
                     "code": "113",
                  "message": "无有效的时效配置"
                },
                {
                  "productCode": "SE003001",
                     "code": "113",
                  "message": "无有效的时效配置"
                }
              ],
                "message": "success",
                "success": true
                }
            } 
            */
            string errcode = "";
            string errmsg = "";
            string resultdata = "";

            string serviceCode = "SCS_RECE_ESTIMATE_DELIVER_TM";
            string msgData = SFCommon.JsonCompress(JsonHelper.SerializeObject(data));
            string timestamp = SFCommon.GetTimeStamp(); //获取时间戳
            string requestID = Guid.NewGuid().ToString(); //获取uuid

            Dictionary<string, string> content = new Dictionary<string, string>();
            content["partnerID"] = partnerID;
            content["requestID"] = requestID;
            content["serviceCode"] = serviceCode;
            content["timestamp"] = timestamp;
            if (!string.IsNullOrWhiteSpace(accessToken))
            {
                content["accessToken"] = accessToken;
            }
            else
            {
                string msgDigest = SFCommon.MD5ToBase64String(SFCommon.UrlEncode(msgData + timestamp + checkword));
                content["msgDigest"] = msgDigest;
            }
            content["msgData"] = msgData;

            var result = HttpHelper.GetResponseApiResultData(content, null, environment);
            if (result != null)
            {
                if (result.apiResultCode == "A1000")
                {
                    var msgDataResponse = JsonHelper.DeserializeObject<ApiResultDataResponseEstimateDeliverTm>(result.apiResultData);
                    if (msgDataResponse != null)
                    {
                        errmsg = msgDataResponse.message;
                        resultdata = JsonHelper.SerializeObject(msgDataResponse.data);
                        if (msgDataResponse.success)
                        {
                            errcode = "0";
                        }
                        else
                        {
                            errcode = msgDataResponse.code;
                        }
                    }
                    else
                    {
                        errcode = "-2";
                        errmsg = "未返回业务数据";
                        resultdata = "";
                    }
                }
                else
                {
                    errcode = result.apiResultCode;
                    errmsg = result.apiErrorMsg;
                    resultdata = result.apiResultData;
                }
            }
            else
            {
                errcode = "-1";
                errmsg = "接口未返回内容";
                resultdata = "";
            }

            return new JsonResult
            {
                errcode = errcode,
                errmsg = errmsg,
                data = resultdata
            };
        }

        /// <summary>
        /// 冷运运输订单取消接口
        /// 客户通过此接口取消已下发顺丰的订单
        /// </summary>
        /// <param name="partnerID"></param>
        /// <param name="checkword"></param>
        /// <param name="data">业务数据报文 json字符串</param>
        /// <param name="environment">调用环境，bspgw：生产环境；sfapi-hk：香港生产环境；sfapi-sbox：沙箱环境</param>
        /// <returns></returns>
        public static JsonResult CancelOrder(string partnerID, string checkword, MsgDataRequestCancelOrder data, string accessToken = "", string environment = "bspgw")
        {
            /*	
            3.报文(JSON)示例
            请求示例

            {
                    "erpOrder": "客户erp单号",
                    "sfOrderNo": "SF生成订单号",
                    "sourceCode": "SFTEST"
            }
            2.3公共返回参数
            参数名	类型	说明	是否必传
            apiResultCode	String(10)	API平台结果代码，详见附录8	Y
            apiErrorMsg	String(200)	API平台异常信息	N
            apiResponseID	String(40)	API响应唯一号UUID	Y
            apiResultData	String	业务处理详细结果	N
            2.4业务返回参数<apiResultData>
            参数名	类型	说明
            code	字符(32)	接口状态 0 成功 其它异常
            message	字符(500)	返回信息展示
            data	字符	
            success	boolean	true 成功 false 异常
            返回示例

            {
               "apiResultCode":"A1000",
               "apiErrorMsg": "",
               "apiResponseID": "161553468411dd",
               "apiResultData":{
                    "code": "0",
                    "data": "",
                    "message": "success",
                    "success": true
                }
            }
            {
                "apiResultCode": "A1099",
                "apiErrorMsg": "系统异常",
                "apiResponseID": "161553468411dd",
                "apiResultData":""
            } 
            */
            string errcode = "";
            string errmsg = "";
            string resultdata = "";

            string serviceCode = "SCS_RECE_CANCEL_ORDER";
            string msgData = SFCommon.JsonCompress(JsonHelper.SerializeObject(data));
            string timestamp = SFCommon.GetTimeStamp(); //获取时间戳
            string requestID = Guid.NewGuid().ToString(); //获取uuid

            Dictionary<string, string> content = new Dictionary<string, string>();
            content["partnerID"] = partnerID;
            content["requestID"] = requestID;
            content["serviceCode"] = serviceCode;
            content["timestamp"] = timestamp;
            if (!string.IsNullOrWhiteSpace(accessToken))
            {
                content["accessToken"] = accessToken;
            }
            else
            {
                string msgDigest = SFCommon.MD5ToBase64String(SFCommon.UrlEncode(msgData + timestamp + checkword));
                content["msgDigest"] = msgDigest;
            }
            content["msgData"] = msgData;

            var result = HttpHelper.GetResponseApiResultData(content, null, environment);
            if (result != null)
            {
                if (result.apiResultCode == "A1000")
                {
                    var msgDataResponse = JsonHelper.DeserializeObject<ApiResultDataResponseCancelOrder>(result.apiResultData);
                    if (msgDataResponse != null)
                    {
                        errmsg = msgDataResponse.message;
                        resultdata = JsonHelper.SerializeObject(msgDataResponse.data);
                        if (msgDataResponse.success)
                        {
                            errcode = "0";
                        }
                        else
                        {
                            errcode = msgDataResponse.code;
                        }
                    }
                    else
                    {
                        errcode = "-2";
                        errmsg = "未返回业务数据";
                        resultdata = "";
                    }
                }
                else
                {
                    errcode = result.apiResultCode;
                    errmsg = result.apiErrorMsg;
                    resultdata = result.apiResultData;
                }
            }
            else
            {
                errcode = "-1";
                errmsg = "接口未返回内容";
                resultdata = "";
            }

            return new JsonResult
            {
                errcode = errcode,
                errmsg = errmsg,
                data = resultdata
            };
        }

        /// <summary>
        /// 冷运运输单号查询接口
        /// 客户通过此接口来查询订单对应的运单号信息(运单号,签回单号,子单号)；
        /// </summary>
        /// <param name="partnerID"></param>
        /// <param name="checkword"></param>
        /// <param name="data">业务数据报文 json字符串</param>
        /// <param name="environment">调用环境，bspgw：生产环境；sfapi-hk：香港生产环境；sfapi-sbox：沙箱环境</param>
        /// <returns></returns>
        public static JsonResult QueryQaybillNo(string partnerID, string checkword, MsgDataRequestQueryQaybillNo data, string accessToken = "", string environment = "bspgw")
        {
            /*
            3.报文(JSON)示例
            请求示例

            {
                "erpOrder": "客户erp单号",
                "sfOrderNo": "SF生成订单号",
                "sourceCode": "SFTEST"
            }
            2.3公共返回参数
            参数名	类型	说明	是否必传
            apiResultCode	String(10)	API平台结果代码，详见附录8	Y
            apiErrorMsg	String(200)	API平台异常信息	N
            apiResponseID	String(40)	API响应唯一号UUID	Y
            apiResultData	String	业务处理详细结果（JSON对象字符串格式：JSON.toJSONString(ResponseModel)	N
            2.4业务返回参数<apiResultData>
            参数名	类型	说明
            code	字符(32)	接口状态 0 成功 其它异常
            message	字符(500)	返回信息展示
            data	对象	model
            success	boolean	true 成功 false 异常
            model对象

            参数名	类型	说明
            erpOrder	字符(64)	运输订单号
            sfOrderNo	字符(64)	SF生成订单号
            waybillNo	字符(64)	SF生成的运单号
            receiptWaybillNo	字符(64)	SF生成的签回单号
            childWaybillNos	数组	SF生成的子单号
            返回示例

            {
               "apiResultCode":"A1000",
               "apiErrorMsg": "",
               "apiResponseID": "161553468411dd",
               "apiResultData":{
                    "code": "0",
                    "data": {
                        "erpOrder": "客户erp单号",
                        "sfOrderNo": "SF生成订单号",
                        "waybillNo":"运单号",
                        "receiptWaybillNo":"签回单号",
                        "childWaybillNos":["子单号1","子单号2"]
                    },
                    "message": "success",
                    "success": true
                }
            }
            {
                "apiResultCode": "A1000",
                "apiErrorMsg": "",
                "apiResponseID": "161553468411dd",
                "apiResultData":{
                    "code": "313",
                    "data": “”,
                    "message": "订单不存在",
                    "success": false
                }
            } 
            */
            string errcode = "";
            string errmsg = "";
            string resultdata = "";

            string serviceCode = "SCS_RECE_QUERY_WAYBILL_NO";
            string msgData = SFCommon.JsonCompress(JsonHelper.SerializeObject(data));
            string timestamp = SFCommon.GetTimeStamp(); //获取时间戳
            string requestID = Guid.NewGuid().ToString(); //获取uuid

            Dictionary<string, string> content = new Dictionary<string, string>();
            content["partnerID"] = partnerID;
            content["requestID"] = requestID;
            content["serviceCode"] = serviceCode;
            content["timestamp"] = timestamp;
            if (!string.IsNullOrWhiteSpace(accessToken))
            {
                content["accessToken"] = accessToken;
            }
            else
            {
                string msgDigest = SFCommon.MD5ToBase64String(SFCommon.UrlEncode(msgData + timestamp + checkword));
                content["msgDigest"] = msgDigest;
            }
            content["msgData"] = msgData;

            var result = HttpHelper.GetResponseApiResultData(content, null, environment);
            if (result != null)
            {
                if (result.apiResultCode == "A1000")
                {
                    var msgDataResponse = JsonHelper.DeserializeObject<ApiResultDataResponseQueryQaybillNo>(result.apiResultData);
                    if (msgDataResponse != null)
                    {
                        errmsg = msgDataResponse.message;
                        resultdata = JsonHelper.SerializeObject(msgDataResponse.data);
                        if (msgDataResponse.success)
                        {
                            errcode = "0";
                        }
                        else
                        {
                            errcode = msgDataResponse.code;
                        }
                    }
                    else
                    {
                        errcode = "-2";
                        errmsg = "未返回业务数据";
                        resultdata = "";
                    }
                }
                else
                {
                    errcode = result.apiResultCode;
                    errmsg = result.apiErrorMsg;
                    resultdata = result.apiResultData;
                }
            }
            else
            {
                errcode = "-1";
                errmsg = "接口未返回内容";
                resultdata = "";
            }

            return new JsonResult
            {
                errcode = errcode,
                errmsg = errmsg,
                data = resultdata
            };
        }

        /// <summary>
        /// 冷运运单路由信息查询
        /// 支持下列三种组合查询
        /// 1.使用运单号(waybillNo)+订单来源(sourceCode)
        /// 2.使用sf的订单号(sfOrderNo)+订单来源(sourceCode)
        /// 3.使用客户订单号(erpOrder)+订单来源(sourceCode)
        /// </summary>
        /// <param name="partnerID"></param>
        /// <param name="checkword"></param>
        /// <param name="data">业务数据报文 json字符串</param>
        /// <param name="environment">调用环境，bspgw：生产环境；sfapi-hk：香港生产环境；sfapi-sbox：沙箱环境</param>
        /// <returns></returns>
        public static JsonResult QueryRoute(string partnerID, string checkword, MsgDataRequestQueryRoute data, string accessToken = "", string environment = "bspgw")
        {
            /*
            3.报文(JSON)示例
            请求示例

            运单号查询：

            {  
                "waybillNo":"978301989046",
                "sourceCode":"SFTEST"
            }
            系统订单号查询：

            {
                "sfOrderNo":"OB342092375611829242-100",
                "sourceCode":"SFTEST" 
            }
            客户 erpOrder 查询冷运订单

            {
                "erpOrder":"PO18101713423778",
                "sourceCode":"SFTEST"
            }
            2.2公共返回参数
            参数名	类型	说明	是否必传
            apiResultCode	String(10)	API平台结果代码，详见附录8	Y
            apiErrorMsg	String(200)	API平台异常信息	N
            apiResponseID	String(40)	API响应唯一号UUID	Y
            apiResultData	String	业务处理详细结果（JSON对象字符串格式：JSON.toJSONString(ResponseModel)	N
            2.4业务返回参数<apiResultData>
            参数名	类型	说明
            code	字符(32)	接口状态 0 成功 其它异常
            message	字符(500)	返回信息展示
            data	List	List<model>
            success	boolean	true 成功 false 异常
            model对象 :

            参数名	类型	是否必填	说明
            routeId	字符	Y	流水号
            barScanTm	日期	Y	巴枪扫描时间
            outsideName	字符	Y	网点对外名称
            distName	字符	Y	所在城市
            opCode	字符	Y	操作类型
            owsRemark	字符	N	官网备注描述
            waybillNo	字符	Y	运单号
            sfOrderNo	字符	Y	SF生成系统订单号
            erpOrder	字符	Y	客户erpOrder订单号
            返回示例

            {
               "apiResultCode":"A1000",
               "apiErrorMsg": "",
               "apiResponseID": "161553468411dd",
               "apiResultData":{
                    "code": "0",
                    "data": [{ 
                        "barScanTm": "2016-07-07 22:00:00",
                        "opCode": "50",
                        "owsRemark": "",
                        "outsideName": "深圳宝安新唐工业园营业部",
                        "distName": "深圳市",
                        "waybillNo":"978301989046",
                        "sfOrderNo":"OB342092375611829242-100",
                        "erpOrder":"PO18101713423778"
                        },
                        {
                        "barScanTm": "2018-12-21 23:59:26",
                        "opCode": "30",
                        "owsRemark": "快件在【深圳清湖食品冷库中转配送部】已装车,准备发往 【深圳五和集散中心】",
                        "outsideName": "深圳清湖食品冷库中转配送部",
                        "distName": "深圳市",
                        "waybillNo":"978301989046",
                        "sfOrderNo":"OB342092375611829242-100",
                        "erpOrder":"PO18101713423778"
                        }],
                    "message": "success",
                    "success": true
                }
            } 
            */
            string errcode = "";
            string errmsg = "";
            string resultdata = "";

            string serviceCode = "SCS_RECE_QUERY_ROUTE";
            string msgData = SFCommon.JsonCompress(JsonHelper.SerializeObject(data));
            string timestamp = SFCommon.GetTimeStamp(); //获取时间戳
            string requestID = Guid.NewGuid().ToString(); //获取uuid

            Dictionary<string, string> content = new Dictionary<string, string>();
            content["partnerID"] = partnerID;
            content["requestID"] = requestID;
            content["serviceCode"] = serviceCode;
            content["timestamp"] = timestamp;
            if (!string.IsNullOrWhiteSpace(accessToken))
            {
                content["accessToken"] = accessToken;
            }
            else
            {
                string msgDigest = SFCommon.MD5ToBase64String(SFCommon.UrlEncode(msgData + timestamp + checkword));
                content["msgDigest"] = msgDigest;
            }
            content["msgData"] = msgData;

            var result = HttpHelper.GetResponseApiResultData(content, null, environment);
            if (result != null)
            {
                if (result.apiResultCode == "A1000")
                {
                    var msgDataResponse = JsonHelper.DeserializeObject<ApiResultDataResponseQueryRoute>(result.apiResultData);
                    if (msgDataResponse != null)
                    {
                        errmsg = msgDataResponse.message;
                        resultdata = JsonHelper.SerializeObject(msgDataResponse.data);
                        if (msgDataResponse.success)
                        {
                            errcode = "0";
                        }
                        else
                        {
                            errcode = msgDataResponse.code;
                        }
                    }
                    else
                    {
                        errcode = "-2";
                        errmsg = "未返回业务数据";
                        resultdata = "";
                    }
                }
                else
                {
                    errcode = result.apiResultCode;
                    errmsg = result.apiErrorMsg;
                    resultdata = result.apiResultData;
                }
            }
            else
            {
                errcode = "-1";
                errmsg = "接口未返回内容";
                resultdata = "";
            }

            return new JsonResult
            {
                errcode = errcode,
                errmsg = errmsg,
                data = resultdata
            };
        }

        /// <summary>
        /// 冷运订单信息查询接口
        /// 客户查询订单更新的详细信息（包括：更新的收寄件人、重量、商品信息、签回单）
        /// </summary>
        /// <param name="partnerID"></param>
        /// <param name="checkword"></param>
        /// <param name="data">业务数据报文 json字符串</param>
        /// <param name="environment">调用环境，bspgw：生产环境；sfapi-hk：香港生产环境；sfapi-sbox：沙箱环境</param>
        /// <returns></returns>
        public static JsonResult QueryOrderInfo(string partnerID, string checkword, MsgDataRequestQueryOrderInfo data, string accessToken = "", string environment = "bspgw")
        {
            /*
            3.报文(JSON)示例
            请求示例

            {
                "erpOrder": "客户erp单号",
                "sourceCode": "订单来源"
            }
            2.3公共返回参数
            参数名	类型	说明	是否必传
            apiResultCode	String(10)	API平台结果代码，详见附录8	Y
            apiErrorMsg	String(200)	API平台异常信息	N
            apiResponseID	String(40)	API响应唯一号UUID	Y
            apiResultData	String	业务处理详细结果（JSON对象字符串格式：JSON.toJSONString(ResponseModel)	N
            2.4业务返回参数<apiResultData>
            参数名	类型	说明
            code	字符(32)	接口状态 0 成功 其它异常
            message	字符(500)	返回信息展示
            data	对象	model
            success	boolean	true 成功 false 异常
            model

            名称	是否必填	类型	描述
            order	Object		
            sourceCode	N	字符(64)	订单来源
            orderNo	N	字符(64)	订单编号
            erpNo	N	字符(64)	ERP单号（客户系统订单号）
            monthlyAccount	N	字符(64)	月结卡号
            orderStatus	N	字符(64)	订单状态
            productCode	N	字符(64)	产品类型代码
            paymentTypeCode	N	字符(64)	付款方式代码
            createTime	N	字符(64)	下单时间
            confirmTime	N	字符(64)	收货确认时间
            signTime	N	字符(64)	签收时间
            temperatureLevelName	N	字符(64)	温层名称
            temperatureLevelCode	N	字符(64)	温层代码
            grossWeight	N	number	实际重量
            meterageWeight	N	number	计费重量
            waybillNo	N	字符(64)	主运单号
            waybillCount	N	integer	运单数量（子母件数量）
            returnWaybillNo	N	字符(64)	签回单号
            pickupType	N	字符(64)	提货方式
            distributionType	N	字符(64)	配送方式
            senderCompany	N	字符(64)	发货公司
            senderName	N	字符(64)	发货人姓名
            senderMobile	N	字符(64)	发货人手机号
            senderPhone	N	字符(64)	发货人座机号
            senderCountryName	N	字符(64)	发货国家名称
            senderProvinceName	N	字符(64)	客户发货地址（小哥收件地址）-省名称
            senderCityName	N	字符(64)	客户发货地址（小哥收件地址）-市名称
            senderAreaName	N	字符(64)	客户发货地址（小哥收件地址）-区名称
            senderDetailAddress	N	字符(64)	客户收货地址（小哥派件地址）-详细地址
            senderWebsiteName	N	字符(64)	客户发货地址（小哥收件地址）-网点名称
            receiverCompany	N	字符(64)	收货公司
            receiverName	N	字符(64)	收货人姓名
            receiverMobile	N	字符(64)	收货人手机号
            receiverCountryName	N	字符(64)	收货国家名称
            receiverProvinceName	N	字符(64)	客户收货地址（小哥派件地址）-省份名称
            receiverCityName	N	字符(64)	客户收货地址（小哥派件地址）-城市名称
            receiverDetailAddress	N	字符(64)	客户收货地址（小哥派件地址）-详细地址
            receiverAreaName	N	字符(64)	客户收货地址（小哥派件地址）-区名称
            receiverWebsiteName	N	字符(64)	收货网点名称
            delivererName	N	字符(64)	派件员姓名
            delivererMobile	N	字符(64)	派件员手机号
            driverName	N	字符(64)	司机姓名
            driverMobile	N	字符(64)	司机手机号
            carNo	N	字符(64)	车牌号
            carType	N	字符(64)	车型
            childWaybillList	Array		子单列表信息
            childWaybillNo	N	字符(64)	子单号
            orderGoodsList	Array		
            skuCode	Y	字符(64)	商品类别
            skuName	Y	字符(128)	商品名称
            quantity	integer	否	箱数,件
            grossWeight	Y	数字(18,3)	实重(kg)
            volume	Y	数字(18,6)	体积(m3)
            sku	N	字符(64)	商品编码SKU
            skuNumber	N	数字(11)	商品数量
            skuUnit	N	字符(32)	计量单位，类似个、只
            remark	N	字符(200)	备注
            orderServiceList	Array		
            monthlyAccount	N	字符(64)	月结卡号
            paymentTypeCode	N	字符(64)	付款方式编码
            serviceCode	N	字符(64)	增值服务编码
            feeAmount	N	number	费用金额
            extensionInfo	N	字符(64)	扩展信息
            orderReturn	Object		
            returnWaybillNo	N	字符(64)	签回单号
            senderCompany	N	字符(64)	发货公司
            senderName	N	字符(64)	发货人
            senderMobile	N	字符(64)	发货人手机号
            senderPhone	N	字符(64)	发货人座机号码
            senderCountryName	N	字符(64)	客户发货地址（小哥收件地址）-国家名称
            senderProvinceName	N	字符(64)	客户发货地址（小哥收件地址）-省名称
            senderCityName	N	字符(64)	客户发货地址（小哥收件地址）-市名称
            senderAreaName	N	字符(64)	客户发货地址（小哥收件地址）-区名称
            senderDetailAddress	N	字符(64)	客户发货地址（小哥收件地址）-详细地址
            receiverCompany	N	字符(64)	收货公司
            receiverName	N	字符(64)	收货人姓名
            receiverMobile	N	字符(64)	收货人手机号
            receiverPhone	N	字符(64)	收货人座机号码
            receiverCountryName	N	字符(64)	客户收货地址（小哥派件地址）-国家名称
            receiverProvinceName	N	字符(64)	客户收货地址（小哥派件地址）-省名称
            receiverCityName	N	字符(64)	客户收货地址（小哥派件地址）-市名称
            receiverAreaName	N	字符(64)	客户收货地址（小哥派件地址）-区名称
            receiverDetailAddress	N	字符(64)	客户收货地址（小哥派件地址）-详细地址
            返回示例

            成功示例

            {
               "apiResultCode":"A1000",
               "apiErrorMsg": "",
               "apiResponseID": "161553468411dd",
               "apiResultData":{
                    "code": "0",
                    "data": {
                        "order": {
                            "orderNo": "TP590256644432453632",
                            "waybillNo": "SF7001013145610",
                            "erpNo": "A01000009",
                            "productCode": "SE003001",
                            "productName": "冷运小票零担",
                            "senderCountryName": "中国",
                            "senderProvinceName": "广东省",
                            "senderCityName": "深圳市",
                            "senderAreaName": "福田区",
                            "senderDetailAddress": "万基商务大厦",
                            "senderWebsiteName": "深圳清湖食品中转场",
                            "senderName": "张三",
                            "senderMobile": "13125478964",
                            "paymentTypeCode": "PR_CASH",
                            "paymentType": "寄付现结",
                            "receiverCountryName": "中国",
                            "receiverProvinceName": "广东省",
                            "receiverCityName": "深圳市",
                            "receiverAreaName": "南山区",
                            "receiverDetailAddress": "彩讯科创中心",
                            "receiverWebsiteName": "深圳清湖食品配送部",
                            "receiverName": "李四",
                            "receiverMobile": "13587456987",
                            "pickupType": "上门提货",
                            "distributionType": "送货上门",
                            "isSpecialWarehousing": "N",
                            "sourceCode": "E-POST",
                            "orderStatus": "已审核",
                            "meterageWeight": 5000,
                            "orderRemark": "测的玩",
                            "createTime": "2021-05-13 16:30:17",
                            "temperatureLevelCode": "2",
                            "temperatureLevelName": "0至10",
                            "returnWaybillNo": "SF7001111675329",
                            "carType":  "4.2米-食品-冷运-冷藏",
                            "importedFlag": 1
                        },
                        "orderServiceList": [{
                                "serviceCode": "VA0021",
                                "serviceName": "保价",
                                "paymentTypeCode": "PR_CASH",
                                "paymentType": "寄付现结",
                                "extensionInfo": "{\"declareValue\":\"50000\"}"
                            },
                            {
                                "serviceCode": "VA0003",
                                "serviceName": "签单返还",
                                "paymentTypeCode": "PR_CASH",
                                "paymentType": "寄付现结",
                                "extensionInfo": "{\"retrunOrderRemark\":\"null\",\"returnOrderType\":\"签名\"}",
                            }
                        ],
                        "orderGoodsList": [{
                            "skuCode": "牛肉",
                            "skuName": "牛肉",
                            "quantity": 10,
                            "grossWeight": 50,
                            "volume": 15
                        }],
                        "orderReturn": {
                            "returnWaybillNo": "SF7001111675329",
                            "receiverName": "张三",
                            "receiverMobile": "13125478964",
                            "receiverCountryName": "中国",
                            "receiverProvinceName": "广东省",
                            "receiverCityName": "深圳市",
                            "receiverAreaName": "福田区",
                            "receiverDetailAddress": "万基商务大厦"
                        }
                    },
                    "message": "success",
                    "success": true
                }
            } 
            */
            string errcode = "";
            string errmsg = "";
            string resultdata = "";

            string serviceCode = "SCS_RECE_QUERY_ORDER_INFO";
            string msgData = SFCommon.JsonCompress(JsonHelper.SerializeObject(data));
            string timestamp = SFCommon.GetTimeStamp(); //获取时间戳
            string requestID = Guid.NewGuid().ToString(); //获取uuid

            Dictionary<string, string> content = new Dictionary<string, string>();
            content["partnerID"] = partnerID;
            content["requestID"] = requestID;
            content["serviceCode"] = serviceCode;
            content["timestamp"] = timestamp;
            if (!string.IsNullOrWhiteSpace(accessToken))
            {
                content["accessToken"] = accessToken;
            }
            else
            {
                string msgDigest = SFCommon.MD5ToBase64String(SFCommon.UrlEncode(msgData + timestamp + checkword));
                content["msgDigest"] = msgDigest;
            }
            content["msgData"] = msgData;

            var result = HttpHelper.GetResponseApiResultData(content, null, environment);
            if (result != null)
            {
                if (result.apiResultCode == "A1000")
                {
                    var msgDataResponse = JsonHelper.DeserializeObject<ApiResultDataResponseQueryOrderInfo>(result.apiResultData);
                    if (msgDataResponse != null)
                    {
                        errmsg = msgDataResponse.message;
                        resultdata = JsonHelper.SerializeObject(msgDataResponse.data);
                        if (msgDataResponse.success)
                        {
                            errcode = "0";
                        }
                        else
                        {
                            errcode = msgDataResponse.code;
                        }
                    }
                    else
                    {
                        errcode = "-2";
                        errmsg = "未返回业务数据";
                        resultdata = "";
                    }
                }
                else
                {
                    errcode = result.apiResultCode;
                    errmsg = result.apiErrorMsg;
                    resultdata = result.apiResultData;
                }
            }
            else
            {
                errcode = "-1";
                errmsg = "接口未返回内容";
                resultdata = "";
            }

            return new JsonResult
            {
                errcode = errcode,
                errmsg = errmsg,
                data = resultdata
            };
        }

        /// <summary>
        /// 冷运运输订单接收接口
        /// 客户通过此接口向冷运下发运输订单
        /// </summary>
        /// <param name="partnerID"></param>
        /// <param name="checkword"></param>
        /// <param name="data">业务数据报文 json字符串</param>
        /// <param name="environment">调用环境，bspgw：生产环境；sfapi-hk：香港生产环境；sfapi-sbox：沙箱环境</param>
        /// <returns></returns>
        public static JsonResult CreateOrder(string partnerID, string checkword, MsgDataRequestCreateOrder data, string accessToken = "", string environment = "bspgw")
        {
            /*
            3.报文(JSON)示例
            请求示例

            {
                    "orderItems": [{
                        "temperatureLevelName": "0至10",
                        "remark": "这是备注",
                        "skuCode": "海鲜水产",
                        "skuName": "海鲜水产",
                        "quantity": "50",
                        "grossWeight": "12",
                        "volume": "12"
                    }],
                    "erpOrder": "1233",
                    "monthlyAccount": "7550612539",
                    "consigneeProvinceName": "广东省",
                    "paymentTypeCode": "PR_ACCOUNT",
                    "shipperLocationName": "宝安M17大厦A栋07",
                    "shipperProvinceName": "广东省",
                    "shipperContactName": "奥特曼",
                    "shipperCityName": "深圳市",
                    "consigneeLocationName": "广东省深圳市南山区深圳南山深南大道58号",
                    "extenSystemOrderNo": "A00000002",
                    "shipperName": "M17星制药",
                    "consigneeCityName": "深圳市",
                    "remark": "这是备注",
                    "consigneeName": "顺丰物流公司",
                    "consigneeContactName": "李生",
                    "consigneeContactTel": "13924222888",
                    "consigneeDistrictName": "宝安区",
                    "shipperContactTel": "13700000002",
                    "shipperDistrictName": "福田区",
                    "productCode": "SE0030",
                    "temperatureLevelCode": "2",
                    "orderTime": "2018-01-01 12:12:12",
                    "transportType": "LAND",
                    "carType":  "4.2米-食品-冷运-冷藏",
                    "orderServices": [{
                            "serviceValue": "签单返还",
                            "serviceCode": "VA0003",
                            "userDef1": "signature,stamp,identityCard,idNo,other",
                            "userDef2": "测试"
                        },
                        {
                            "serviceValue": "3000",
                            "serviceCode": "VA0021"
                        },
                        {
                            "serviceCode": "VA0075",
                            "serviceValue": "资源调节费"
                        }, {
                            "serviceCode": "VA003701",
                            "serviceValue": "装车服务"
                        }, {
                            "serviceCode": "VA003702",
                            "serviceValue": "卸车服务"
                        }, {
                            "serviceCode": "VA0058",
                            "serviceValue": "提货服务"
                        }, {
                            "serviceCode": "VA0059",
                            "serviceValue": "配送服务"
                        }
                    ]
            }
            精简报文

            {
                    "consigneeCityName": "蚌埠市",
                    "consigneeContactName": "钱多多",
                    "consigneeContactTel": "18400001111",
                    "consigneeDistrictName": "淮上区",
                    "consigneeLocationName": "安徽启航资产管理有限公司双墩路营业部",
                    "consigneeProvinceName": "安徽省",
                    "erpOrder": "ERP181323202891",
                    "monthlyAccount": "7551990789",
                    "orderItems": [{
                        "grossWeight": 13.0,
                        "quantity": 1.0,
                        "skuCode": "海鲜水产",
                        "skuName": "海鲜水产",
                        "volume": 33.0
                    }],
                    "orderServices": [{
                        "serviceCode": "VA0021",
                        "serviceValue": "333"
                    }],
                    "orderTime": "2018-06-12 12:12:12",
                    "paymentTypeCode": "PR_ACCOUNT",
                    "productCode": "SE0030",
                    "remark": "测试订单",
                    "shipperCityName": "深圳市",
                    "shipperContactName": "李四",
                    "shipperContactTel": "18699998888",
                    "shipperDistrictName": "南山区",
                    "shipperLocationName": "学府路软件产业基地",
                    "shipperProvinceName": "广东省",
                    "sourceCode": "公司简称+系统代码(防止重复)",
                    "temperatureLevelCode": "3",
                    "transportType": "LAND",
                    "freightFee": 0
            }
            2.3公共返回参数
            参数名	类型	说明	是否必传
            apiResultCode	String(10)	API平台结果代码	Y
            apiErrorMsg	String(200)	API平台异常信息	N
            apiResponseID	String(40)	API响应唯一号UUID	Y
            apiResultData	String	业务处理详细结果（JSON对象字符串格式：JSON.toJSONString(ResponseModel)	N
            2.4业务返回参数<apiResultData>
            参数名	类型	说明
            code	字符(32)	接口状态 0 成功 其它异常
            message	字符(500)	返回信息展示
            data	对象	model
            success	boolean	true 成功 false 异常
            model对象

            参数名	类型	说明
            sfOrderNo	字符(64)	SF生成订单号 (失败不产生)
            erpOrder	字符(64)	外部系统订单号(客户方系统订单号)
            返回示例

            成功示例

            {
               "apiResultCode":"A1000",
               "apiErrorMsg": "",
               "apiResponseID": "161553468411dd",
               "apiResultData": {
                "code": "0",
                "data": {
                    "erpOrder": "ERP00000001",
                    "sfOrderNo": "SF000000000000000001"
                },
                "message": "success",
                "success": true
                } 
            }
            错误示例

            {
               "apiResultCode": "A1099",
                "apiErrorMsg": "系统异常",
                "apiResponseID": "161553468411dd",
                "apiResultData":""
            }
            4.附录
            4.1增值服务
            服务名称	服务代码	说明	备注
            签单返还	VA0003	签名-signature,盖章-stamp,登记身份证-identityCard,收取身份证复印件-idNo,其他-other	签单返回代码以,形式存放userDef1
            备注内容存放userDef2
            保价	VA0021	保价金额存放serviceValue字段	保价
            装车服务	VA003701		
            卸车服务	VA003702		
            提货服务	VA0058	勾选此服务可以选择填写 提货时间段，必须传了提货服务，才会上门提货	提货时间规则：
            当天12点之前，
            可以选 当天下午13:00-18:00,
            明天和后天 08:00-12:00 13:00-18:00
            当天12点之后，
            可选 明天和后天 08:00-12:00 13:00-18:00
            配送服务	VA0059	选择此服务可以填写 送达时间段，必须传了配送服务，才会送货上门	
            动检证	VA0035	acceptanceStamp是动物盖章
            renewalStamp动检换证	动检证代码以,形式存放userDef1字段
            例如：
            “userDef1”:“acceptanceStamp,renewalStamp”
            特殊入仓	VA0001	提供派件以外的额外服务（如排队等候、轮候验收）配送至需繁琐交接流程的特殊区域（如码头、仓库等），减少客户沟通成本。	
            4.2温层对照表
            温层代码	温层名称	温区
            2	0至10	冷藏
            5	18至22	18至22
            9	0至4	0至4
            10	-18以下	-18以下
            30	冷冻	冷冻
            31	常温（环境温度）	常温（环境温度）
            4.3产品类型对照表
            产品代码	产品类型名称
            SE0030	冷运大件到港
            SE003001	冷运大件标快
            SE0031	冷运整车
            SE0059	冷运到店
            SE003003	冷运专线
            4.4付款方式对照表
            付款方式代码	付款方式名称
            AR	到付
            PR_CASH	寄付现结
            PR_ACCOUNT	寄付月结
            4.5物品类别对照表
            物品类别
            海鲜水产
            畜禽肉
            酒水饮料
            乳制品
            果蔬
            速冻包点
            餐饮食材
            冰淇淋
            其他
            4.6车辆类型对照表
            车辆类型	最大装载数量
            15.0米-食品-冷运-常温	30T
            15.0米-食品-冷运-冷藏	30T
            15.0米-食品-冷运-冷冻	30T
            16.5米-食品-冷运-冷冻	30T
            16.5米-食品-冷运-冷藏	30T
            16.5米-食品-冷运-常温	30T
            13.5米-食品-冷运-冷冻	20T
            13.5米-食品-冷运-冷藏	20T
            13.5米-食品-冷运-常温	20T
            9.6米-食品-冷运-冷冻	14T
            9.6米-食品-冷运-冷藏	14T
            9.6米-食品-冷运-常温	14T
            7.6米-食品-冷运-冷冻	7T
            7.6米-食品-冷运-冷藏	7T
            7.6米-食品-冷运-常温	7T
            5.2米-食品-冷运-冷冻	3.5T
            5.2米-食品-冷运-冷藏	3.5T
            5.2米-食品-冷运-常温	3.5T
            4.2米-食品-冷运-冷冻	1.5T
            4.2米-食品-冷运-冷藏	1.5T
            4.2米-食品-冷运-常温	1.5T
            4.7错误码对照表
            编码	备注
            20050	处理失败
            20051	订单号不能为空
            20052	参数校验不通过通用信息
            20053	参数状态校验不通过
            20054	ID不能为空
            20055	地址编号不能为空
            20056	多地址收件网点必须一致
            20057	外部订单号+手机号重复
            20058	地址信息不存在
            20059	作业单号不能为空
            200060	订单不存在
            200061	订单状态不合适
            20062	系统繁忙,请稍后再试
            20063	基础参数不能为空
            20064	多地址信息不能为空
            20065	参数校验不通过，具体原因自己写
            20066	运单信息查询失败,请稍后重试
            20067	用户信息校验不通过
            20068	订单所属分公司不存在
            20069	月结卡号对应的客户信息不存在
            20070	月结卡号对应的客户信息不存在
            20071	订单对应的第三方付卡号所属网点不存在
            20072	没有生效的寄转第三方协议
            20073	寄转第三方校验失败
            20074	未找到基础网点信息
            20075	网点信息失效
            20076	月结卡号未开通转区内和区外功能
            20077	订单对应的第三方付卡号所属网络代码分公司系统中不存在
            20078	产品类型不能为空
            20079	产品类型不存在
            20080	运单已经确认收货,无法修改收发货信息
            20081	暂不支持修改签单返回增值服务
            20082	ERP单号已经存在
            20083	运单号已经存在
            20084	冷运专车的一口价费用必须为大于0的数字
            20084	一口价必须大于0
            20085	多地址不存在商品明细,请维护后再进行复制
            20086	此增值服务不存在
            20087	运输方式不支持
            20088	月结卡号不能为空
            20089	请确定金额是否为数字
            20090	时间范围不正确
            20091	订单已受理,无法取消
            20092	金额不在范围内
            20093	待收货款增值服务必须包含金额
            20094	保价增值服务必须包含保价金额
            20095	车牌号不能为空
            20096	只有冷运专车才可以下返程车订单
            20097	司机姓名不能为空
            20098	司机联系方式不能为空
            20099	当前产品类型不支持此支付方式
            20100	司机联系方式格式错误
            20101	每次最多操作一百条
            10000	ERP单号重复
            100001	订单不存在
            100002	参数错误
            100003	订单已受理,无法修改
            10004	ERP单号不能为空
            10005	订单已经取消
            10006	订单尚未生成运单信息,请稍后重试
            9999	系统处理失败,请稍后重试
            500	处理失败 
            */
            string errcode = "";
            string errmsg = "";
            string resultdata = "";

            string serviceCode = "SCS_RECE_CREATE_ORDER";
            string msgData = SFCommon.JsonCompress(JsonHelper.SerializeObject(data));
            string timestamp = SFCommon.GetTimeStamp(); //获取时间戳
            string requestID = Guid.NewGuid().ToString(); //获取uuid

            Dictionary<string, string> content = new Dictionary<string, string>();
            content["partnerID"] = partnerID;
            content["requestID"] = requestID;
            content["serviceCode"] = serviceCode;
            content["timestamp"] = timestamp;
            if (!string.IsNullOrWhiteSpace(accessToken))
            {
                content["accessToken"] = accessToken;
            }
            else
            {
                string msgDigest = SFCommon.MD5ToBase64String(SFCommon.UrlEncode(msgData + timestamp + checkword));
                content["msgDigest"] = msgDigest;
            }
            content["msgData"] = msgData;

            var result = HttpHelper.GetResponseApiResultData(content, null, environment);
            if (result != null)
            {
                if (result.apiResultCode == "A1000")
                {
                    var msgDataResponse = JsonHelper.DeserializeObject<ApiResultDataResponseCreateOrder>(result.apiResultData);
                    if (msgDataResponse != null)
                    {
                        errmsg = msgDataResponse.message;
                        resultdata = JsonHelper.SerializeObject(msgDataResponse.data);
                        if (msgDataResponse.success)
                        {
                            errcode = "0";
                        }
                        else
                        {
                            errcode = msgDataResponse.code;
                        }
                    }
                    else
                    {
                        errcode = "-2";
                        errmsg = "未返回业务数据";
                        resultdata = "";
                    }
                }
                else
                {
                    errcode = result.apiResultCode;
                    errmsg = result.apiErrorMsg;
                    resultdata = result.apiResultData;
                }
            }
            else
            {
                errcode = "-1";
                errmsg = "接口未返回内容";
                resultdata = "";
            }

            return new JsonResult
            {
                errcode = errcode,
                errmsg = errmsg,
                data = resultdata
            };
        }
        
        #endregion 冷运运输类

        #region 冷运仓储类

        #endregion 冷运仓储类
    }
}
